package com.yunfeisoft.business.service.impl;

import com.yunfeisoft.business.dao.inter.BedDao;
import com.yunfeisoft.business.dao.inter.RoomDao;
import com.yunfeisoft.business.model.Room;
import com.yunfeisoft.business.service.inter.RoomService;
import com.yunfeisoft.common.base.BaseServiceImpl;
import com.yunfeisoft.common.utils.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * ClassName: RoomServiceImpl
 * Description: 房间service实现
 * Author: Jackie liu
 * Date: 2020-01-13
 */
@Service("roomService")
public class RoomServiceImpl extends BaseServiceImpl<Room, String, RoomDao> implements RoomService {

    @Autowired
    private BedDao bedDao;

    @Override
    public Page<Room> queryPage(Map<String, Object> params) {
        return getDao().queryPage(params);
    }

    @Override
    public List<Room> queryListCondition(Map<String, Object> params) {
        return getDao().queryListCondition(params);
    }

    @Override
    public List<Room> listAll(Map<String, Object> params) {
        return getDao().listAll(params);
    }

    @Override
    public int save(Room room) {
        bedDao.batchInsert(room.getBedList());
        return super.save(room);
    }

    @Override
    public int modify(Room room) {
        bedDao.deleteByRoomId(room.getId());
        bedDao.batchInsert(room.getBedList());
        return super.modify(room);
    }
}